
<div class="panel panel-default">
 <div class="panel-heading"><label>${apiInfo.description}</label>&nbsp;:&nbsp;<label >${apiInfo.url}</label></div>
 <div class="panel-body">

	<ul id="myTab" class="nav nav-tabs">
		<li class="active">
			<a href="#info" data-toggle="tab">
				 描述
			</a>
		</li>
		<li><a href="#debug" data-toggle="tab">测试</a></li>
		
	</ul>
	<div id="myTabContent" class="tab-content">
		<div class="tab-pane fade in active" id="info">
			<div class="panel panel-default">
				<table class='table table-bordered'>
					<tr>
						<td width="10%" align="left">
							<label>描述</label>
						</td>
						<td width="20%">${apiInfo.description}</td>
						<td width="10%">method</td>
						<td width="60%">${apiInfo.fullName}</td>
					</tr>
					<tr>
						<td width="10%">requestMethod</td>
						<td width="20%" >${apiInfo.requestMethod}</td>
						<td width="10%">contentType</td>
						<td width="60%">${apiInfo.contentType}</td>
					</tr>
				</table>
			</div>
			
			<div class="panel panel-default">
			  <div class="panel-heading">参数列表</div>
			  <div class="panel-body">
			    <table class='table table-bordered'>
			    	<tr>
			    		<th colspan="3" width="20%">名称</th>
			    		<th width="30%">类型</th>
			    		<th width="50%">说明</th>
			    	</tr>
			    	#foreach($para in $apiInfo.parameters)
			    	<tr>
			    		<td colspan="3">${para.name}</td>
			    		<td >${para.typeName.replace("<","&lt;")}</td>
			    		<td >${para.description}</td>
			    	</tr>
			    		#foreach($subParam in $para.children)
				    	<tr>
				    		<td>&nbsp;</td>
				    		<td  colspan="2">${subParam.name}</td>
				    		<td >${subParam.typeName}</td>
				    		<td >${subParam.description}</td>
				    	</tr>
					    	#foreach($subsub in $subParam.children)
					    	<tr >
					    		<td>&nbsp;</td>
					    		<td>&nbsp;</td>
					    		<td >${subsub.name}</td>
					    		<td >${subsub.typeName.replace("<","&lt;")}</td>
					    		<td >${subsub.description}</td>
					    	</tr>
					    	#end
						    	
				    	#end
			    	#end
			    	#if($apiInfo.parameters.size()==0)
			    		<tr>
		    				<td colspan=5>无</td>
		    			</td>
			    	#end
			    </table>
			  </div>
			</div>
			
			<div class="panel panel-default">
			  <div class="panel-heading">返回值</div>
			  <div class="panel-body">
			   <table class='table table-bordered'>
			    	<tr>
			    		<th colspan="4" width="20%">名称</th>
			    		<th width="30%">类型</th>
			    		<th width="50%">说明</th>
			    	</tr>
			    	<tr>
			    		<td colspan="4">return</td>
			    		<td >${apiInfo.result.parameter.typeName.replace("<","&lt;")}</td>
			    		<td >${apiInfo.result.parameter.description}</td>
			    	</tr>
			    	#foreach($sub in $apiInfo.result.parameter.children)
				    	<tr>
				    		<td>&nbsp;</td>
				    		<td  colspan="3">${sub.name}</td>
				    		<td >${sub.typeName.replace("<","&lt;")}</td>
				    		<td >${sub.description}</td>
				    	</tr>
				    		#foreach($subsub in $sub.children)
						    	<tr>
						    		<td>&nbsp;</td>
						    		<td>&nbsp;</td>
						    		<td colspan="2">${subsub.name}</td>
						    		<td >${subsub.typeName.replace("<","&lt;")}</td>
						    		<td >${subsub.description}</td>
						    	</tr>
						    #end
							    #foreach($grandson in $subsub.children)
						    	<tr>
						    		<td>&nbsp;</td>
						    		<td>&nbsp;</td>
						    		<td colspan="2">${grandson.name}</td>
						    		<td >${grandson.typeName.replace("<","&lt;")}</td>
						    		<td >${grandson.description}</td>
						    	</tr>
						    	#end
				    	#end
			    </table>
			  </div>
			</div>
		</div>
		
		
		
		<div class="tab-pane fade" id="debug">
			<div class="panel panel-default">
			  <div class="panel-heading">请求</div>
			  <!--requestBody=true用textArea,false用from-->
			  <div class="panel-body">
			  <form id="fm" >
			    <table class='table table-bordered'>
			    #if($apiInfo.requestJson!=true)
			    	#foreach($para in ${apiInfo.debugParams})
			    	<tr>
			    		<td width="10%" >${para.inputName}</td>
			    		<td width="50%"><input type="text" class="form-control" placeholder="${para.placeholder}" validate="${para.validate}" name="${para.inputName}"></td>
			    		<td width="40%" >
			    			<label class="control-label" >${para.description}</label>
			    		</td>
			    	</tr>
			    	#end
			    </table>
			    #end
			    #if($apiInfo.requestJson)
			    <table class='table table-bordered' >
			    	<tr>
			    		<td>
			    			<textarea  id="requestContent" style="width:100%;height:300px" >${apiInfo.jsonParam}</textArea>
			    		</td>
			    	</tr>
			    </table>
			    #end
			    <button type="button" class="btn btn-primary" onclick=subForm()>提交</button>
			  </div>
			  </form>
			</div>
			
			<div class="panel panel-default">
			  <div class="panel-heading">返回</div>
			  <div class="panel-body">
			   	<pre id="result">
				</pre>
			  </div>
			</div>
		</div>
	</div>

</div>
</div>

<script type="text/javascript">
function subForm(){
	var url='${apiInfo.url}';
	var requestJson='${apiInfo.requestJson}';
	var contentType='${apiInfo.contentType}';
	
	if(requestJson=="true"){
		$('#result').html('');
		data=$("#requestContent").val();
		ajaxUtil.postJson(url,data,function(resp){
			$('#result').html(common.jsonToStr(resp))
		});
		return;
	}
	
	if(!validate.valiForm($("#fm")[0])){
		return;
	}
	$('#result').html('');
	if(contentType.indexOf('json')!=-1){
		common.postForm('fm',url,function(resp){
			$('#result').html(common.jsonToStr(resp))
		});
	}else{
		var data=$("#"+'fm').serialize();
		url=url+'?'+data;
		common.getHtml(url,function(resp){
			$('#result').text(resp)
		});
	}
}
</script>



